package com.daydayup.stream;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class StreamTest3 {
    public static void main(String[] args) {
        List<Student> students = new ArrayList<Student>();
        for (int i = 0; i < 10; i++) {
            Student student = new Student();
            student.setName("张三" + i);
            student.setAge(i);
            students.add(student);
        }

        System.out.println(students);

        List<String> names = new ArrayList<>();
        names.add("张三0");
        names.add("张三1");
        names.add("张三2");

        List<Student> newStudent = students.stream().filter(e -> names.contains(e.getName())).collect(Collectors.toList());
        //students.removeAll(newStudent);
        System.out.println(newStudent);
        System.out.println(students);

        System.out.println("----------------");
        String name = "张三2";
        StreamTest3 test = new StreamTest3();
        List<Student> stus = students.stream().filter(e -> test.matchName(e)).collect(Collectors.toList());
        System.out.println(stus);
    }

    private boolean matchName(Student student){
        switch (student.getName()) {
            case "张三2":
            case "张三1":
            case "张三0":
                return true;
        }
        return false;
    }

}
